package cool.doudou.doudada.mqtt.core.factory;

import cool.doudou.doudada.mqtt.core.callback.MqttSubscribeCallback;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * CallbackMapFactory
 *
 * @author jiangcs
 * @since 2022/3/3
 */
public class CallbackMapFactory {
    private static final Map<String, MqttSubscribeCallback> map = new ConcurrentHashMap<>();

    public static MqttSubscribeCallback get(String topic) {
        return map.get(topic);
    }

    public static void add(String topic, MqttSubscribeCallback callback) {
        map.put(topic, callback);
    }
}
